<!--红云超市-->
<template>
  <article class="page mine-page">
    <div class="header">
      <div @click="tools.back()" class="back"><span class="arrow"></span></div>
      <div class="head-bd">
        红云超市
      </div>
      <!-- <div @click="detail()" class="message"><div class="head-btn-text">兑换记录</div></div>-->
    </div>

    <section class="frame-content-sub no-bg">
      <div class="score-hd">
        <h1 class="score">{{myIntegrals.totalScore}}</h1>
        <p class="tip">当前积分，继续努力</p>
      </div>

      <section class="">

        <section class="block goods-list">
          <div  @click="exchange" class="item">
            <div class="cont">
              <div class="img"><img src="../../../../static/images/dangjian/mine/reanswer.png" alt=""></div>
              <div class="cont-text-wrap">
                <h1 class="title">补答题</h1>
                <div class="tip">兑换后立即进入问答页面进行回答</div>
                <div class="tip-sub color-red">150积分</div>
              </div>
            </div>
            <div @click="exchange" class="btn btn-red">兑换</div>
          </div>
        </section>


      </section>


      <div class="pdv-0"></div>
    </section>
  </article>
</template>

<script>
  import progressBar from '@/components/common/progressBar.vue'
  import moment from 'moment'
  import tools from '@/utils/tools'
  export default {
    components: {progressBar},
    name: 'superMarket',
    data () {
      return {
        fn: tools,
        userInfo: {},
        partyInfo: {},
        sysFile: {},
        todayData: {},
        myIntegrals: {}
      }
    },
    created () {
      this.userInfo = this.$localStorage.get('userInfo')
      let pInfo = this.$localStorage.get('partyInfo')
      if (pInfo) {
        this.partyInfo = pInfo
      }
      // this.getFile()
      this.myIntegral()
    },
    methods: {
      exchange () {
        /*if (this.myIntegrals.totalScore < 150) {
          return this.tools.alert('积分不够')
        }*/
        let params = {
          loginId: this.userInfo.id
        }
        this.tools.showLoading()
        this.fetchService.pointConvertId(params).then(res => {
          console.log('res.data', res.data)
          this.tools.hideLoading()
          if (res.code !== 0) {
            return tools.tip(res.message)
          }
          let data = {
            groupId: res.data.id,
            pointExchangeId: res.data.pointExchangeId
          }
          this.fetchService.pointConvertInfo(data).then(res => {
            this.$store.state.answerScoreData = res.data
            this.$router.push({name: 'oneAnswerEveryday', query: {fromSuperMarket: true}})
          })
        })
      },
      go (path) {
        this.$router.push({path: path})
      },
      getFile () {
        let fileId = this.userInfo.photo
        this.fetchService.sysFile(fileId).then(res => {
          if (res.code !== 0) {
            // return tools.tip(res.message)
          }
          this.sysFile = res.data
        })
      },
      myIntegral () {
        let data = {
          userId: this.userInfo.id
        }
        this.fetchService.myIntegral(data.userId).then(res => {
          if (res.code !== 0) {
             return tools.tip(res.message)
          }
          this.myIntegrals = res.data
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "@/common/stylus/moon.scss";
  .mine-page{
    background: url("../../../../static/images/dangjian/mine/bg-mine-hd.png") $bg-color no-repeat center #{pxToRem($head-height)};
    background-size: 100% auto;
    padding:0;
    .header {
      justify-content: space-between;
      margin-bottom: pxToRem(0px);
      position: relative;
    }
  }

  .score-hd {
    height:242px;
    text-align: center;
    background: url("../../../../static/images/dangjian/mine/bg-mine-hd.png") $theme-color no-repeat center;
    background-size: 100% auto;

    .score {
      font-size:56px;
      line-height:1em;
      font-weight:400;
      color:rgba(255,255,255,1);
      padding-top:50px;
    }

    .tip {
      font-size:12PX;
      font-weight:400;
      color:rgba(255,255,255,1);
    }
  }

  .red-car {
    position: relative;
    margin-top:-60px;
    background:#fff;
    display:flex;
    justify-content:flex-start;
    align-items:center;
    padding:29px 34px;
    margin-bottom:0;
    &::after {
      position:absolute;
      top:50%;
      right:40px;
      transform:translateY(-50%);
      content:'';
      width: pxToRem(16px);
      height: pxToRem(25px);
      background:rgba(199,199,204,1);
      background: url("../../../../static/images/dangjian/dangwu/arrow-left.png") no-repeat center;
      background-size: auto 100%;
    }

    .img {
      width:101px;
      height:94px;
      margin-right:32px;
      img {
        @include fullImg();
      }
    }

    .cont {
      .title {
        font-size:30px;
        line-height: 1em;
        font-weight:400;
        color:rgba(51,51,51,1);
      }

      .tip {
        font-size:24px;
        font-weight:400;
        color:rgba(153,153,153,1);
      }
    }
  }

  .goods-list {
    padding:10px 30px;
    .hd {
      .hd-title {
        font-size: 36px;
        font-weight: bold;
        color: rgba(51, 51, 51, 1);
      }

      .tip {
        font-size:24px;
        font-weight:400;
        color:rgba(51,51,51,1);
        line-height:60px;
        span {
          padding-left:10px;
        }
      }
    }

    .item {
      display:flex;
      justify-content:space-between;
      align-items:center;
      padding:37px 0;
      border-bottom:1px solid $border-color;
      &:last-child {
        border:none;
      }
      .cont {
        display:flex;
        justify-content: space-between;
        align-items:center;
        .img {
          width:140px;
          height:140px;
          position: relative;
          overflow: hidden;
          border-radius:10px;
          text-align: center;
          margin-right:25px;
          img {
            position: absolute;
            z-index:2;
            width:100%;
            top:50%;
            left:0;
            transform: translateY(-50%);
          }
        }
        .title {
          font-size:$titleFontSize;
          font-weight:400;
          color:rgba(51,51,51,1);
        }
        .tip {
          font-size:$tipFontSize;
          font-weight:400;
          color:rgba(153,153,153,1);
        }
        .tip-sub {
          display:flex;
          font-size:$titleFontSize;
          font-weight:400;
          color:rgba(153,153,153,1);
          .progress {
            font-size:0;
          }
        }
      }
      .btn {
        width:114px;
        height:60px;
        line-height:60px;
        background:rgba(242,242,242,1);
        border-radius:4px;
        font-size:28px;
        font-weight:400;
        color:rgba(102,102,102,1);
        text-align: center;
        &.btn-red {
          background:rgba(255,255,255,1);
          border:1px solid $theme-color;
          border-radius:4px;
          font-size:28px;
          font-weight:400;
          color:$theme-color;
        }
      }
    }
  }
</style>
